import type { App } from 'vue'

// 不可异步 - dom 计算宽高异常
import title from './title/index.vue'
import tagList from './tag-list/index.vue'
import card from './card/index.vue'
import sliderBar from './slider-bar/index.vue'
import count from './count/index.vue'
import tableColumn from './table-column/index.vue'
import select from './select/index.vue'
import pagination from './pagination/index.vue'
import form from './form/index.vue'
import dialogForm from './dialog-form/index.vue'
import table from './table/index.vue'
import desc from './desc/index.vue'
import drag from './drag/index.vue'

// 定义一个数组存放要注册的组件
const components = [
  { name: 'z-card', component: card },
  { name: 'z-title', component: title },
  { name: 'z-tag-list', component: tagList },
  { name: 'z-slider-bar', component: sliderBar },
  { name: 'z-count', component: count },
  { name: 'z-table-column', component: tableColumn },
  { name: 'z-select', component: select },
  { name: 'z-pagination', component: pagination },
  { name: 'z-form', component: form },
  { name: 'z-dialog-form', component: dialogForm },
  { name: 'z-table', component: table },
  { name: 'z-desc', component: desc },
  { name: 'z-drag', component: drag }
]

const install = (app: App) => {
  components.forEach(({ name, component }) => {
    app.component(name, component) // 注册组件时直接使用手动指定的名称
  })
}

export default install
